package value;

import java.util.Arrays;

/**
 * @Author Mucd
 * @ClassName BubbleSort
 * @Date 2020/12/8/008
 * @Specification Alibaba
 */
public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 123, 213, 123, 123, 22};
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - i; j++) {
                //相邻两元素对比
                if (arr[j] > arr[j + 1]) {
                    //元素交换
                    int temp = arr[j + i];
                    arr[j + 1] = arr[j];
                    arr[j] = temp;
                }

            }
            System.out.println(Arrays.toString(arr));
        }
    }

}
